#open(SAMP,"merge_affy.fam") or die "no file exists merge_final.fam\n";
#open(WRBUFF,">Duplicates");
#open(WRREPLACE,">Replace");
#while(<SAMP>)
#{
#	chomp($_);
#	@samp=split(" ",$_);
#	$samp{$samp[1]}=$_;
#}
open(PLINK,"plink.genome") or die "no file found plink.genome\n";
#$line=<PLINK>;
$val=0;
while($line=<PLINK>)
{
	chomp($line);
	$line =~ s/^\s+//g;
	@array=split(/\s+/,$line);
	#print $array[1]."\t".$array[3]."\t".$array[9]."\n";
	if($array[9] >0.9)
	{
		if(exists($hash{$array[1]}) && exists($hash{$array[3]}))
		{
			#die "$array[1]  $hash{$array[1]} $array[3] $hash{$array[3]} already exists\n";
		}
		elsif(exists($hash{$array[1]}))
		{
			$hash{$array[3]} = $hash{$array[1]};
		}
		elsif(exists($hash{$array[3]}))
		{
			$hash{$array[1]} =$hash{$array[3]};
		}
		else
		{
			$val++;
			$hash{$array[1]} = $val;
			$hash{$array[3]} = $val;	
		}
		#print WRBUFF "$array[1] $hash{$array[1]}\n$array[3] $hash{$array[3]}\n";
	}
}
#print "size of hash:  " . keys( %hash ) . ".\n";
$prev=-1;
$pp="";
$mm=0;	
foreach $key (sort {$hash{$a} <=> $hash{$b} } keys %hash)
{     
	#print "$key  $hash{$key}\n";
	#print "$key  $hash{$key}\n";
	if( $prev == $hash{$key})
	{
		#print  WRBUFF $samp{$key}."\n";
		#print WRREPLACE $pp."\n";
		$mm++;	
	}
	else
	{
		$pp=$samp{$key};
	}	
	$prev=$hash{$key};
}
print $mm."\n";
